<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>

  <script>
    /* 
    */
    new Promise((resolve, reject) => {
      // resolve(1)
      reject(2)
    }).then(
      value => {
        console.log('onResolved1', value)
        throw 3
        // return Promise.reject(3)
      },
      reason => {
        console.log('onRejected1', reason)
        return 4
      }
    )
    .catch(reason => {
      console.log('catch onRejected', reason)
    })
    // .then(
    //   value => value,
    //   reason => {
    //     console.log('catch onRejected', reason)
    //   }
    // ) // 返回成功的promise, 且value为接收的value
    .then(
      value => {
        console.log('onResolved3', value)
      },
      reason => {
        console.log('onRejected3', reason)
      }
    )
    .finally(() => { // 当promise变为成功或失败时都会调用
      console.log('finally 回调')
    })

    /* 
    catch(onRejected)的本质:
    then(
      value => value,
      onRejected
    )

    */

  </script>
</body>
</html>